'''
Created on Apr 22, 2012

@author: samindaw
'''


#import nltk
#from nltk.corpus import wordnet as wn
#
#cats=wn.synsets("wolf")
#dogs=wn.synsets("dog")
#best_cat=None
#best_dog=None
#best_compare=0
#for cat in cats:
#    for dog in dogs:
##        cat.load_ic
#        value=cat.wup_similarity(dog)
#        if (value!=None and best_compare<value):
#            best_compare=value
#            best_cat=cat
#            best_dog=dog
#
#print best_compare
#print best_cat.lemma_names
#print best_dog.lemma_names

#a=[1,2,3,4,5,6]
#print a[:-1]
def long_substr(data):
    substr = ''
    if len(data) > 1 and len(data[0]) > 0:
        for i in range(len(data[0])):
            for j in range(len(data[0])-i+1):
                if j > len(substr) and all(data[0][i:i+j] in x for x in data):
                    substr = data[0][i:i+j]
    return substr
a="abc"
b="xyz"
print ">"+long_substr([a,b])+"<"
#from nltk.corpus import wordnet as wn
#
#
#
#def getSenseSimilarity(worda,wordb):
#
#    """
#
#    find similarity betwwn word senses of two words
#
#    """
#
#    wordasynsets = wn.synsets(worda)
#
#    wordbsynsets = wn.synsets(wordb)
#
#    synsetnamea = [wn.synset(str(syns.name)) for syns in wordasynsets]
#
#    synsetnameb = [wn.synset(str(syns.name)) for syns in wordbsynsets]
#
#
#
#    for sseta, ssetb in [(sseta,ssetb) for sseta in synsetnamea
#
#    for ssetb in synsetnameb]:
#
#        pathsim = sseta.path_similarity(ssetb)
#
#        wupsim = sseta.wup_similarity(ssetb)
#
#        if pathsim != None:
#
#            print "Path Sim Score: ",pathsim," WUP Sim Score: ",wupsim,"\t"#,sseta.definition, "\t", ssetb.definition
#
#
#
#if __name__ == "__main__":
#
#    #getSenseSimilarity('cat','walk')
#
#    getSenseSimilarity('wolf','dog')